package com.net.oil.user.presenter;

import com.net.oil.base.BasePresenter;
import com.net.oil.user.bean.UserInfo;
import com.net.oil.user.contract.LoginContract;
import com.net.oil.user.model.LoginModel;

/**
 * 作者：lch
 * 时间：2018/3/14:9:48
 * 邮箱：245850413@qq.com
 * 说明：
 */

public class LoginPresenter extends BasePresenter<LoginContract.View> implements LoginContract.Presenter {

    private LoginContract.View view;
    private LoginContract.Model model;

    public LoginPresenter(LoginContract.View view) {
        this.view = view;
        this.model = new LoginModel(this);
    }

    @Override
    protected void unSubscribe() {
        model.unSubscribe();
    }

    @Override
    public void login(String phone, String password) {
        model.login(phone, password);
    }

    @Override
    public void loginSuccess(UserInfo userInfo) {
        view.loginSuccess(userInfo);
    }

    @Override
    public void loginFailed() {
        view.loginFailed();
    }

    @Override
    public void getPhoneCode(String phone, boolean ptt) {
        model.getPhoneCode(phone, ptt);
    }

    @Override
    public void getPhoneCodeSuccess() {
        view.getPhoneCodeSuccess();
    }

    @Override
    public void getPhoneCodeFailed() {
        view.getPhoneCodeFailed();
    }

    @Override
    public void loginByAuthCode(String phone, String code) {
        model.loginByAuthCode(phone, code);
    }

    @Override
    public void loginByAuthCodeSuccess(UserInfo userInfo) {
        view.loginByAuthCodeSuccess(userInfo);
    }

    @Override
    public void loginByAuthCodeFailed() {
        view.loginByAuthCodeFailed();
    }
}
